package com.jy.api.service;

import com.jy.api.domain.*;
import com.jy.api.enums.InstanceEnum;
import com.jy.api.signUpReq.clerk.CouponInstanceSignUpReq;
import com.jy.api.signUpReq.pos.PaymentSignUpReq;
import com.jy.api.vo.admin.coupon.CouponInstanceDetailsVo;
import com.jy.api.vo.pos.coupon.CouponInstanceVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.security.Principal;
import java.text.ParseException;
import java.util.List;

/**
 * Created by lihu on 2017/11/17.
 */
public interface CouponInstanceService {

    /**
     * 优惠卷发放
     *
     * @param instanceSignUpReq
     */
    String addCouponInstance(CouponInstanceSignUpReq instanceSignUpReq, Principal principal) throws Exception;

    /**
     * 校验优惠卷
     *
     * @return
     */
    CouponInstance checkCouponInstance(String code, String id);

    /**
     * 核销优惠卷
     *
     * @param order
     */
    void writeOffCouponInstance(Order order, PaymentSignUpReq paymentSignUpReq);

    void writeOffCouponInstanceByOrderId(Order order);

    /**
     * 获取会员对应店铺可使用优惠卷
     *
     * @param memberId
     * @param storeId
     * @return
     */
    CouponInstanceVo getMemberStoreCouponInstance(String memberId, String storeId, Pageable pageable);

    /**
     * 获取会员对应状态优惠卷
     *
     * @param memberId
     * @param stauts
     * @param pageable
     * @return
     */
    CouponInstanceVo getMemberStatusCouponInstance(String memberId, CouponInstanceStatus stauts, String storeId, Pageable pageable);


    /**
     * 获取店铺优惠卷信息统计
     *
     * @param storeId
     * @return
     */
    List<CountClickAndShareRes> getCouponInstanceTotal(String storeId, String type, String begin, String end, String time, Pageable pageable);

    /**
     * 获取优惠卷核销信息
     *
     * @param storeId
     * @param pageable
     * @return
     */
    Page<CouponInstance> getvalidate(String storeId, Pageable pageable);

    /**
     * 获取优惠卷详情
     *
     * @param id
     * @return
     */
    CouponInstanceDetailsVo getCouponInstanceDetails(String id);

    /**
     * 后台优惠卷发放
     *
     * @param coupon
     * @param memberId
     */
    void addCouponInstance(Coupon coupon, String memberId, String creatorId, String creatorName)throws Exception;

    /**
     * 校验(会员是否已领取过)优惠卷
     *
     * @param openId
     * @param couponInstanceId
     * @return
     */
    InstanceEnum checkMemberCouponAuth(String openId, String couponInstanceId);
}
